﻿using System;
using System.Collections;
using System.Collections.Generic;
namespace WPFExcelReport
{
    public class PurchaseReport : BaseReport
    {
        string strCompany = "HLT";
        string strExcelFile = "";
        public PurchaseReport()
            : base()
        {
        }
        public PurchaseReport(Dictionary<string, object> dicParamater)
            : base(dicParamater)
        { 
            strCompany = dicParamater["Company"].ToString().Trim();
            strExcelFile = dicParamater["ExcelFile"].ToString().Trim();
            
           
        }
        private void PurchaseMaterial_COLUMNS()
        {
            columns.Add("CODE");columns.Add("ART"); columns.Add("VAR"); columns.Add("DES"); columns.Add("FARBE");
            columns.Add("COLOR");columns.Add("AUFKRS");columns.Add("AUFLFD");columns.Add("AUFPOS");columns.Add("LIEFNR");
            columns.Add("SUPPLIER"); columns.Add("ORDERQTY"); columns.Add("UNIT"); columns.Add("PRICE");
            columns.Add("ORDERDATE"); columns.Add("STARTDATE"); columns.Add("ENDDATE"); columns.Add("INCOMEDATE");
            columns.Add("BATCH"); columns.Add("SUPPLIERBATCH"); columns.Add("WEI"); columns.Add("DIFF");
            columns.Add("DIFF1"); 
        }

        public void PurchaseMaterial_TO_EXCEL(string fileType)
        {  
            Queue CellQueue = new Queue();
            PurchaseMaterial_COLUMNS();
            string filename = "";
            string sheetName = "";
            string Standard = "Purchase_Material_PO";
            strExcelFile = @"HLT\HLTSummaryReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = "";
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Purchase\采购原料报表" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":","");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInData(columns, dsSource.Tables["EKPOS"]); 
            if (exAgent != null)
            {
                exAgent.Save();
                exAgent.Close();
            }
        }

        private void Supp_Pur_Summ_COLUMNS()
        {
            columns.Add("LIEFNR"); columns.Add("SUPPLIER"); columns.Add("QUANTITY"); columns.Add("VALUE");
        }

        public void Supp_Pur_Summ_TO_EXCEL(string fileType)
        {
            Queue CellQueue = new Queue();
            Supp_Pur_Summ_COLUMNS();
            string filename = "";
            string sheetName = "";
            string Standard = "Purchase_PO_Summary";
            strExcelFile = @"HLT\HLTSummaryReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = "";
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Purchase\供应商采购量" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInData(columns, dsSource.Tables["PURCHASE_SUPP_SUMM"]);
            if (exAgent != null)
            {
                exAgent.Save();
                exAgent.Close();
            }
        }

        private void Pur_Mat_List_COLUMNS()
        {
            columns.Add("CODE"); columns.Add("ART"); columns.Add("VAR"); columns.Add("DES");
            columns.Add("FARBE"); columns.Add("COLOR"); columns.Add("AUFKRS"); columns.Add("AUFLFD");
            columns.Add("AUFPOS"); columns.Add("LIEFNR"); columns.Add("SUPPLIER"); columns.Add("ORDERQTY"); columns.Add("UNIT");
            columns.Add("PRICE"); columns.Add("ORDERDATE"); columns.Add("STARTDATE"); columns.Add("ENDDATE"); 
            columns.Add("DELQTY"); columns.Add("VALUE"); 
            
        }

        public void Pur_Mat_List_TO_EXCEL(string fileType)
         {
             Queue CellQueue = new Queue();
             Pur_Mat_List_COLUMNS();
             string filename = "";
             string sheetName = "";
             string Standard = "Purchase_PO_List";
             strExcelFile = @"HLT\HLTSummaryReport.xls";
             string filePath = @"C:\intex.w\Report\" + strExcelFile;
             exAgent.Open(filePath);
             exAgent.Company = "";
             exAgent.strExcelFile = strExcelFile;
             string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
             filename = @"Purchase\原料订购记录" + filedate + ".xls";
             sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
             exAgent.CreateNewSheet(filename, Standard, sheetName);
             FillInData(columns, dsSource.Tables["Pur_Mat_List"]);
             if (exAgent != null)
             {
                 exAgent.Save();
                 exAgent.Close();
             }
         }

        private void Material_Inventory_COLUMNS()
        {
            columns.Add("CODE"); columns.Add("ART"); columns.Add("VAR"); columns.Add("COLOR");
            columns.Add("SUPPLIER"); columns.Add("INCOMEDATE");  columns.Add("BATCH");
            columns.Add("SUPPLIERBATCH"); columns.Add("WEI"); columns.Add("ALLOWEI"); 
          
        }

        public void Material_Inventory_TO_EXCEL(string fileType)
        {
            Queue CellQueue = new Queue();
            Material_Inventory_COLUMNS();
            string filename = "";
            string sheetName = "";
            string Standard = "Purchase_Yarn_Stock";
            strExcelFile = @"HLT\HLTSummaryReport.xls";
            string filePath = @"C:\intex.w\Report\" + strExcelFile;
            exAgent.Open(filePath);
            exAgent.Company = "";
            exAgent.strExcelFile = strExcelFile;
            string filedate = DateTime.Now.Year.ToString() + DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
            filename = @"Purchase\纱线库存报表" + filedate + ".xls";
            sheetName = DateTime.Now.ToShortTimeString().Replace(@":", "");
            exAgent.CreateNewSheet(filename, Standard, sheetName);
            FillInData(columns, dsSource.Tables["INVENTORY_YARN"]);
            if (exAgent != null)
            {
                exAgent.Save();
                exAgent.Close();
            }
        }
    }

}
